package com.jeeplus.modules.api.wxtx;

import com.google.common.collect.Maps;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Map;
/**
 * @author kk
 * 微信提现
 */
public class WechatExtract {
	public static void main(String[] args) throws Exception {
        //提现金额(单位:元)
        String result = "2";
        Map<String, String> map = Maps.newHashMap();

        //元转换为分,微信支付已分为单位
        BigDecimal sumAmount = new BigDecimal(result);
        //乘以100，转换为分
        BigDecimal transAmt = sumAmount.multiply(new BigDecimal(100)); 



        //订单号
        String Order = "F"+LocalDate.now().toString().replace("-", "")+LocalTime.now().toString().replace("-", "").replace(":","").replace(".", "");
        //随机字符串
        map.put("nonce_str", OtherUtil.getNonceStr().toString());
        //openid("c从数据库中查询")
        //map.put("openid",openid.get(0).getUserlevel());
        map.put("openid","ocYeu0V9WccmTP9axyCp_tDscUN0");
        //金额
        map.put("amount",transAmt.toString());
        ////企业付款操作说明信息
        map.put("desc","提现测试");

        //调用支付
        String returnInfo =  WeChatWithdrawUtils.withdrawRequestOnce(map,3000,3000,true);
        Map<String,String> resultMap = OtherUtil.readStringXmlOut(returnInfo);

        if(resultMap.containsKey("result_code") && "SUCCESS".equals(resultMap.getOrDefault("result_code",""))){
            System.out.println("提现成功");
            System.out.println("返回结果："+returnInfo);
        }else{
            System.out.println("提现成功");
            System.out.println("返回结果："+returnInfo);
        }
    }
}
